<template>
  <div class="comment-reply">
    <!-- 导航栏 -->
    <van-nav-bar
     :title="`${comment.reply_count}条回复`"
     >
      <van-icon
        slot="left"
        name="cross"
        @click="$emit('close')"
      />
   </van-nav-bar>
    <!-- /导航栏 -->

    <!-- 当前评论项 -->
     <div class="scroll-warp">
        <comment-item :comment="comment"/>
    <!-- /当前评论项 -->

    <van-cell title="所有回复" />
    <comment-list
    :list="commentList"
    :source="comment.com_id"
    type="c"
    />
     </div>
    <!-- 评论的回复列表 -->
    <div class="post-warp">
      <van-button
       class="post-btn"
       size="small"
       round
       @click="isPostShow = true"
       >写评论</van-button>
    </div>
    <!-- /评论的回复列表 -->
      <van-popup v-model="isPostShow" position="bottom">
        <comment-post
         :target="comment.com_id"
         @post-success="onPostCuccess"
        />
      </van-popup>
    <!-- 底部 -->
    <!-- /底部 -->
  </div>
</template>

<script>
import CommentItem from './comment-item'
import CommentList from './comment-list'
import CommentPost from './comment-post'
export default {
  name: 'CommentReply',
  components: {
    CommentItem,
    CommentList,
    CommentPost
  },
  props: {
    comment: {
      type: Object,
      required: true
    }
  },
  data () {
    return {
      isPostShow: false,
      commentList: []
    }
  },
  computed: {},
  watch: {},
  created () {},
  mounted () {},
  methods: {
    onPostCuccess (data) {
      this.comment.reply_count++
      this.isPostShow = false
      this.commentList.unshift(data.new_obj)
    }
  }
}
</script>

<style scoped lang="less">
.scroll-warp {
  position: fixed;
  top: 92px;
  left: 0;
  right: 0;
  bottom: 88px;
  overflow-y: auto;
}
.post-warp {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border-top: 1px solid #d8d8d8;
     .post-btn {
       width: 60%;

     }
}
</style>
